package com.hpeu_01.day0119.homework;

/**
 * 第一题：开发一个泛型Apple类，要求有一个重量属性weight在测试类中实例化不同的泛型对象，
 * 要求对象a1的这一属性是String类型，对象a2的这一属性是Integer型，a3的这一属性是Double型。
 * 分别为a1，a2，a3的重量属性赋值为：”500克”，500,500.0，在测试类中通过对象调用访问器得到属性值并输出。
 */
public class HomeWork04 {
    public static void main(String[] args) {
        Apple<String> a1 = new Apple<>("500克");
        Apple<Integer> a2 = new Apple<>(500);
        Apple<Double> a3 = new Apple<>(500.0);
        System.out.println(a1.toString());
        System.out.println(a2.toString());
        System.out.println(a3.toString());
    }
}
class Apple<T>{
    private T weight;

    public T getWeight() {
        return weight;
    }

    public void setWeight(T weight) {
        this.weight = weight;
    }

    public Apple(T weight) {
        this.weight = weight;
    }

    public Apple() {
    }

    @Override
    public String toString() {
        return "Apple{" +
                "weight=" + weight +
                '}';
    }
}